﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DungeonGenerator
{

    // Define other methods and classes here
    public interface IRandomize
    {
        bool NextBool();
        int Next(int bound1, int bound2); //should accept min/max in any order
        int NextSign();
    }
    public class TestRandomizer : IRandomize
    {
        readonly Random _rnd;

        public TestRandomizer(int seed)
        {
            _rnd = new Random(seed);
        }
        public int RandomsCount { get; private set; }
        public bool NextBool()
        {
            RandomsCount++;
            //http://stackoverflow.com/a/1493094/57883
            //upperbound is exclusive
            return _rnd.Next(0, 2) ==0;
        }
        public int NextInclusive(int bound1, int bound2)
        {
            RandomsCount++;
            var min = Math.Min(bound1, bound2);
            var max = Math.Max(bound1, bound2);
            return _rnd.Next(min, max+1);
        }
        public int Next(int bound1, int bound2)
        {
            RandomsCount++;
            var min = Math.Min(bound1, bound2);
            var max = Math.Max(bound1, bound2);
            return _rnd.Next(min, max);
        }
        public int NextSign()
        {
            RandomsCount++;
            var negative = NextBool();
            return negative ? -1 : 1;
        }
    }
}
